//
//  XSChartViewModel.m
//  Test
//
//  Created by xueshan1 on 2018/12/13.
//  Copyright © 2018 xueshan1. All rights reserved.
//

#import "XSChartViewModel.h"

@implementation XSChartViewModel
- (instancetype)init
{
    self = [super init];
    if (self) {
        _plotButtons = [NSMutableArray array];
    }
    return self;
}

+ (XSChartViewModel *)modelWithName:(NSString *)name color:(UIColor *)color dataSource:(NSArray *)dataSource{
    XSChartViewModel *model = [[XSChartViewModel alloc]init];
    model.name = name;
    model.color = color;
    if (model.color == nil) {
        model.color = [UIColor blackColor];
    }
    model.dataSource = dataSource;
    if (dataSource.count > 0) {
        model.maxValue = [dataSource.firstObject integerValue];
        for (int i = 0;i<dataSource.count; i++) {
            if (model.maxValue < [dataSource[i] integerValue]) {
                model.maxValue = [dataSource[i] integerValue];
            }
        }
        
    }
    
    return model;
}

@end
